//
//  CustomTextViewAlertView.m
//  Credit
//
//  Created by WangZhenyu on 16/5/20.
//  Copyright © 2016年 WangZhenyu. All rights reserved.
//

#import "CustomTextViewAlertView.h"

@interface CustomTextViewAlertView(){
    BOOL        editBool;
}

@end

@implementation CustomTextViewAlertView

- (id)initItemTitle:(NSString *)title placeholder:(NSString *)str editTextView:(BOOL)edit{
    self = [[[NSBundle mainBundle] loadNibNamed:@"CustomTextViewAlertView" owner:self options:nil] lastObject];
    if (self) {
        [self setFrame:CGRectMake(0, 0, 280, 242)];
        self.titleLabel.text = title;
        self.contentTextView.layer.masksToBounds = YES;
        self.contentTextView.layer.borderColor = [LineColor CGColor];
        self.contentTextView.layer.borderWidth = 0.5f;
        
        editBool = YES;
        
        self.contentTextView.text = str;
        
        self.contentTextView.editable = edit;
        if (edit) {
            [self.contentTextView setTextColor:RGB(150, 150, 150)];
        }else{
            [self.contentTextView setTextColor:RGB(45, 45, 45)];
        }
    }
    return self;
}

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    if (editBool) {
        editBool = NO;
        textView.text = @"";
        [textView setTextColor:RGB(45, 45, 45)];
    }
    return YES;
}

@end
